//
//  MyWalletViewController.m
//  Manage
//
//  Created by 杨康 on 2018/1/10.
//  Copyright © 2018年 杨康. All rights reserved.
//

#import "MyWalletViewController.h"
#import "MydepositViewController.h"
#import "PaymentViewController.h"
#import "RechargeViewController.h"
@interface MyWalletViewController ()
{
    UILabel *_mydepositLab;
    UILabel *_stateLab;
    UIView *_bottomView;
    UILabel *_tipLab;
    UIButton *_tipButton;
    
    
    
    //测试
    NSInteger type;
}
@end

@implementation MyWalletViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"我的钱包";
    UIImageView *bgImg=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"余额背景"]];
    [self.view addSubview:bgImg];
    [bgImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(20+TOP_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-30, (SCREEN_WIDTH-30)*40/69));
    }];
    bgImg.userInteractionEnabled=YES;
    
    
    UILabel *titleLab=[SingLeton myLabel:[UIColor colorWithHexString:@"222222"] andTitle:@"余额" andFont:18];
    [bgImg addSubview:titleLab];
    [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(40);
        make.centerX.mas_equalTo(bgImg);
        
    }];
    
    
    UILabel *numLab=[SingLeton myLabel:[UIColor colorWithHexString:@"09be00"] andTitle:@"0.00" andFont:30];
    [bgImg addSubview:numLab];
    [numLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(bgImg);
        make.top.mas_equalTo(titleLab.mas_bottom).mas_offset(10);
    }];
    
    
    
    YKButton *payButton=[SingLeton endButton:[UIColor colorWithHexString:@"09be00"] andTitle:@"充值" RequestSuccess:^(UIButton *btn) {
        RechargeViewController *vc=[[RechargeViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }];
    [bgImg addSubview:payButton];
    [payButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-15);
        make.centerX.mas_equalTo(bgImg);
        make.size.mas_equalTo(CGSizeMake(260, 40));
    }];
    
    
    UIView *stateView=[[UIView alloc]init];
    [self.view addSubview:stateView];
    [stateView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(bgImg.mas_bottom);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 95));
    }];
    
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(mydepositAction)];
    [stateView addGestureRecognizer:tap];
    
    
    
    
    
    
    
    UILabel *mymoneyLab=[[UILabel alloc]init];
    [stateView addSubview:mymoneyLab];
    [mymoneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(stateView);
        make.left.mas_equalTo(15);
    }];
    
    
    NSString *str0=@"我的押金";
    NSString *str1=@"(1000元)";
    
    mymoneyLab.attributedText=[NetworkPath setRichText:str0 withFont:16 withColor:[UIColor colorWithHexString:@"222222"] andOtherText:str1 withFont:16 withColor:[UIColor colorWithHexString:@"09be00"] atIndex:4];
    
    _mydepositLab=mymoneyLab;
    
    
    
    
    UILabel *stateLab=[SingLeton myLabel:[UIColor colorWithHexString:@"ff3649"] andTitle:@"未交纳" andFont:14];
    
    [stateView addSubview:stateLab];
    [stateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-25);
        make.centerY.mas_equalTo(stateView);
    }];
    _stateLab=stateLab;
    
    UIImageView *tipImg=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"箭头"]];
    [stateView addSubview:tipImg];
    [tipImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(stateView);
        make.right.mas_equalTo(-15);
    }];
    
    
    
    
    UILabel *lineLab=[[UILabel alloc]init];
    [self.view addSubview:lineLab];
    [lineLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(stateView.mas_bottom);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-30, 1));
    }];
    lineLab.backgroundColor=[UIColor colorE];
    
    
    //测试
    type=0;
    UIButton *segButton=[SingLeton endButton:[UIColor colorQ] andTitle:@"切换" RequestSuccess:^(UIButton *btn) {
        type++;
        if (type==3) {
            type=0;
        }
        [self updateAction];
    }];
    [self.view addSubview:segButton];
    [segButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(lineLab.mas_bottom).mas_offset(2);
        make.right.mas_equalTo(lineLab.mas_right);
        make.size.mas_equalTo(CGSizeMake(60, 30));
    }];
    
   
    
    UIView *bottomView=[[UIView alloc]init];
    [self.view addSubview:bottomView];
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 50));
    }];
    bottomView.backgroundColor=[UIColor colorWithHexString:@"09be00"];
    _bottomView=bottomView;
    
    UILabel *tipLab=[SingLeton myLabel:[UIColor whiteColor] andTitle:@"您尚未交纳押金，有押金更实惠。" andFont:14];
    [bottomView addSubview:tipLab];
    [tipLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(bottomView);
        
    }];
    _tipLab=tipLab;
    
    UIButton *paymButton=[SingLeton endButton:nil andTitle:@"交纳押金" RequestSuccess:^(UIButton *btn) {
        PaymentViewController *vc=[[PaymentViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }];
    [bottomView addSubview:paymButton];
    [paymButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 30));
        make.centerY.mas_equalTo(bottomView);
        make.right.mas_equalTo(-15);
    }];
    paymButton.titleLabel.font=[UIFont systemFontOfSize:14];
    paymButton.layer.borderWidth=1;
    paymButton.layer.borderColor=[UIColor whiteColor].CGColor;
    _tipButton=paymButton;
    
}
-(void)updateAction
{
    switch (type) {
        case 0:
        {
            _bottomView.hidden=NO;
            
            NSString *str0=@"我的押金";
            NSString *str1=@"(1000元)";
            
            _mydepositLab.attributedText=[NetworkPath setRichText:str0 withFont:16 withColor:[UIColor colorWithHexString:@"222222"] andOtherText:str1 withFont:16 withColor:[UIColor colorWithHexString:@"09be00"] atIndex:4];
            
            
            
            
            
            _stateLab.text=@"未交纳";
            _stateLab.textColor=[UIColor colorWithHexString:@"ff3649"];
            _stateLab.textColor=[UIColor color9];
            
            
            
            _tipLab.text=@"您尚未交纳押金，有押金更实惠。";
            [_tipButton setTitle:@"交纳押金" forState:UIControlStateNormal];
        }
            break;
        case 1:
        {
            _bottomView.hidden=YES;
            _mydepositLab.text=@"我的押金";
            _stateLab.text=@"已交纳";
            _stateLab.textColor=[UIColor color9];
            
        }
            break;
        case 2:
        {
            _bottomView.hidden=NO;
            _mydepositLab.text=@"我的押金";
            _stateLab.text=@"3个工作日内退回";
            _stateLab.textColor=[UIColor color9];
            _tipLab.text=@"押金退款中，无法享受熊猫充电的服务。";
            [_tipButton setTitle:@"取消退款" forState:UIControlStateNormal];
        }
            break;
        default:
            break;
    }
}
-(void)mydepositAction
{
    MydepositViewController *vc=[[MydepositViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
    
}



@end
